 
package com.mixide.ui.part;

import javax.inject.Inject;

import java.util.Objects;

import javax.annotation.PostConstruct;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;

import com.mixide.ui.service.MixHolder;

public class ComparisonIndicatorPart {
	
	private Display display;
	private MixHolder mix;
	
	public @Inject ComparisonIndicatorPart(Display display, MixHolder mix) {
		this.display = display;
		this.mix = mix;
	}
	
	@PostConstruct
	public void postConstruct(Composite parent) {
		parent.setBackground(this.display.getSystemColor(SWT.COLOR_WHITE));
		GridLayout layout = new GridLayout(3, false);
		parent.setLayout(layout);
		Button gt = new Button(parent, SWT.TOGGLE);
		gt.setText("GT");
		Button eq = new Button(parent, SWT.TOGGLE);
		eq.setText("EQ");
		Button lt = new Button(parent, SWT.TOGGLE);
		lt.setText("LT");
		
		if (Objects.isNull(this.mix.ci().get())) {
			return;
		}
		
		switch (this.mix.ci().get()) {
		case GREATER:
			gt.setSelection(true);
			break;
		case EQUAL:
			eq.setSelection(true);
			break;
		case LESS:
			lt.setSelection(true);
			break;
		default:
			break;
		}
	}
}